﻿@model int
@{
    ViewBag.Title = "test2";
 
}
<header>
    <link href="~/Content/search/jquery.autocomplete.css" rel="stylesheet" />
    <script src="~/Content/search/jquery.autocomplete.js"></script>
    <link href="~/Content/bookEvent.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.9.1.js"></script>
    <script src="~/Scripts/jquery-ui-1.8.24.js"></script>
  
</header>

<script>
    $(function () {
        $('#groupName').autocomplete({
            source: function (request, response) {
              
                $.ajax({
                    url: '@Url.Action("AutoCompleteGroup")',
                    dataType: "json",
                    contentType: 'application/json, charset=utf-8',
                    data: {
                        search: $("#groupName").val()
                    },
                    success: function (data) {

                        var mData = JSON.parse(data);// tóm lại là vẫn phải convert lại  :3 

                        response($.map(mData, function (item) {
                            return {
                                value: item,
                            };
                        }));
                    },
                    error: function (xhr, status, error) {
                        alert(error);
                    }
                });

            },
            minLength: 1,
            select: function (event, ui) {
                var values = ui.item.value;
                $.ajax({
                  type: 'GET',
                 url: '@Url.Action("_showGroupPartial")',
                 dataType: 'json',
                 data: { groupName: values },
                 contentType: "application/json; charset=utf-8",
                 success: function (json) {
                     //alert(json);
                     document.getElementById("divListMember").innerHTML = "Members: " + "<strong>"+ json +"</strong>";
                 },
                 error: function (xhr, status, error) {
                     alert(error);
                 }
                });
            },
        });
    });

</script>


@using (Html.BeginForm("Index", "GroupMember",FormMethod.Post))
{
    <div class="ui-widget">
    <label for="groupName">Group Name </label>
   @* <input id="groupName" style="width: 200px" type="text" />*@
    @Html.Editor("groupName",null,new{@Styles="width: 200px"})
    <div id="divListMember">

   </div>
         @Html.Hidden("eventID",Model)
    <input type="submit" value="Add" name="addAllMem" />
</div> 
}

<div id="lblUserId"></div>
@* addAllMem----------------------------------------------------------------------------------------------------- *@
@*<script>

    $(document).ready(function () {
        $("input[name='addAllMem']").click(function () {
            var groupName = $("#groupName").val();
            var eventID = $("#eventID").val();
            var string = "{'groupName:'" + groupName + "'," + "'eventID':'" + eventID + "'" + "}";
        
            $.ajax({
                type: 'POST',
                url: '@Url.Action("_inviteGroupPartial", "GroupMember")',
                dataType: 'json',
                data: string,
                contentType: "application/json; charset=utf-8",
                success: function (mess) {
                    alert(mess);
                },
                error: function (xhr, status, error) {
                    alert(error);

                }

            });
            alert("kk");
        });
    });
</script>*@
@* showMem------------------------------------------------------------------------------------------------------ *@

